home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 2 / Deutsche Edition 2.iso / mac / TEXT / OzTeX 1.7 ƒ / TeX-inputs / Plain / boxedeps.tex < prev    next >
Text File  |  1994-05-18  |  25KB  |  782 lines

  1.   %%
  2.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3.   %%
  4.  %%%%%               boxedeps.tex 
  5.  %%%%% MACROS FOR FIGURE INSERTS OF EPSF NORM  %%%%%
  6.  %%%%%   (EPSF = Encapsulated PostScript File)
  7.   %%
  8.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9.   %%  
  10.  %%%  AUTHOR: Laurent Siebenmann
  11.   %%    lcs@matups.matups.fr
  12.   %%  
  13.  %%%  VERSIONS: Feb 1991 -- Jan 1994
  14.   %%  
  15.  %%%  SOMMAIRE: boxedeps.tex d\'efinit des macro-commandes
  16.   %%    qui permettent d'int\'egrer dans un document TeX des 
  17.   %%    objets graphiques d\'ecrits par fichier de norme EPSF,
  18.   %%    tout en accordant a chacun le statut d'une bo\^ite TeX ayant 
  19.   %%    les bonnes dimensions.  La (seule!) contribution unique 
  20.   %%    de ce fichier est de faire cela d'une fa{\c}con universelle.
  21.   %%    C'est a dire de fa{\c}con \`a pouvoir commod\'ement 
  22.   %%    servir avec tout pilote d'imprimante de norme 
  23.   %%    PostScript --- malgr\'e l'absence d'une norme 
  24.   %%    pour \special. 
  25.   %%  
  26.  %%%% ACTIVATION:
  27.   %%  by a driver-by-driver protocol
  28.   %%  see \SetOzTeXEPSFSpecial 
  29.   %%  and its companions below.
  30.   %%  
  31.  %%%% DOCUMENTATION:
  32.   %%  --- see boxedeps.doc
  33.   %%  The complete utility is called BoxedEPSF
  34.   %%  (or boxedeps for the MSDOS world).
  35.   %%
  36.  %%%  POSTINGS: anonymous ftp 
  37.   %%  ---  ftp matups.matups.fr [192.54.146.4] 
  38.   %%  This is the master copy in 1994.
  39.   %%  ---  ftp.uni-stuttgart.de 
  40.   %%  ---  ftp ftp.TeX.AC.UK
  41.   %%  ---  ftp ftp.SHSU.edu
  42.   %%  Locate the full package on these three 
  43.   %%  "CTAN" servers by using (while connected) the command
  44.   %%        QUOTE SITE INDEX boxedeps
  45.  
  46.  \ifx\MYUNDEFINED\BoxedEPSF
  47.    \let\temp\relax
  48.  \else
  49.    \message{}
  50.    \message{ !!! \string\BoxedEPSF or \string\BoxedArt %
  51.          macros already defined !!!}
  52.    \let\temp\endinput
  53.  \fi
  54.   \temp
  55.  
  56.  \chardef\EPSFCatAt\the\catcode`\@
  57.  \catcode`\@=11
  58.  
  59.  \chardef\C@tColon\the\catcode`\:
  60.  \chardef\C@tSemicolon\the\catcode`\;
  61.  \chardef\C@tQmark\the\catcode`\?
  62.  \chardef\C@tEmark\the\catcode`\!
  63.  \chardef\C@tDqt\the\catcode`\"
  64.  
  65.  \def\PunctOther@{\catcode`\:=12
  66.    \catcode`\;=12 \catcode`\?=12 \catcode`\!=12 \catcode`\"=12}
  67.  \PunctOther@
  68.  
  69.  %%temporarily suppress Plain's logging of allocations
  70.  \let\wlog@ld\wlog 
  71.  \def\wlog#1{\relax} 
  72.  
  73.  %% New for TOOLS
  74.  %\newif\ifIN@
  75.  \newdimen\XShift@ \newdimen\YShift@ 
  76.  \newtoks\Realtoks
  77.  
  78.  %%% New for BoxedEPSF
  79.  %
  80.  \newdimen\Wd@ \newdimen\Ht@
  81.  \newdimen\Wd@@ \newdimen\Ht@@
  82.  %
  83.  \newdimen\TT@
  84.  \newdimen\LT@
  85.  \newdimen\BT@
  86.  \newdimen\RT@
  87.  %
  88.  \newdimen\XSlide@ \newdimen\YSlide@ 
  89.  %
  90.  \newdimen\TheScale  %% secretly scale in mils: 1pt= 1mil 
  91.  \newdimen\FigScale  %% secretly scale in mils: 1pt= 1mil 
  92.  %
  93.  \newdimen\ForcedDim@@
  94.  
  95.  \newtoks\EPSFDirectorytoks@
  96.  \newtoks\EPSFNametoks@
  97.  \newtoks\BdBoxtoks@
  98.  \newtoks\LLXtoks@  %% useful info for PSprint
  99.  \newtoks\LLYtoks@  
  100.  
  101.   
  102.  \newif\ifNotIn@
  103.  \newif\ifForcedDim@
  104.  \newif\ifForceOn@
  105.  \newif\ifForcedHeight@
  106.  \newif\ifPSOrigin
  107.  
  108.  \newread\EPSFile@ 
  109.  
  110.  %%%% MESSAGES (separate macro best for Europe)
  111.   %%  
  112.   \def\ms@g{\immediate\write16}
  113.  
  114.  %%%% WORD-PROCESSING MACROS
  115.   %%
  116.   %%% \IN@0#1@#2@ : Is 1st exp of #1 in 1st exp of #2 ??
  117.    %% Answer in \ifIN@
  118.  \newif\ifIN@\def\IN@{\expandafter\INN@\expandafter}
  119.   \long\def\INN@0#1@#2@{\long\def\NI@##1#1##2##3\ENDNI@
  120.     {\ifx\m@rker##2\IN@false\else\IN@true\fi}%
  121.      \expandafter\NI@#2@@#1\m@rker\ENDNI@}
  122.   \def\m@rker{\m@@rker}
  123.  
  124.   %%%  \SPLIT@0#1@#2@  :  Split 1st exp of #2 at 1st exp of #1
  125.    %%  \Initialtoks@ , \Terminaltoks@ will contain pieces
  126.   \newtoks\Initialtoks@  \newtoks\Terminaltoks@
  127.   \def\SPLIT@{\expandafter\SPLITT@\expandafter}
  128.   \def\SPLITT@0#1@#2@{\def\TTILPS@##1#1##2@{%
  129.      \Initialtoks@{##1}\Terminaltoks@{##2}}\expandafter\TTILPS@#2@}
  130.  
  131.  %%%% MACROS TO TRIM  \ForeTrim@0#1@ and \Trim@0#1@  
  132.    %% result appears in \Trimtoks@
  133.    %% LIMITATION: assume no multiple spaces to trim
  134.  
  135.   \newtoks\Trimtoks@
  136.  
  137.   %%% \ForeTrim@0#1@ trims initial space of first erpansion of #1
  138.    %% #1 of form \the\toks0 or \mymacro
  139.  \def\ForeTrim@{\expandafter\ForeTrim@@\expandafter}
  140.  \def\ForePrim@0 #1@{\Trimtoks@{#1}}
  141.  \def\ForeTrim@@0#1@{\IN@0\m@rker. @\m@rker.#1@%
  142.      \ifIN@\ForePrim@0#1@%
  143.      \else\Trimtoks@\expandafter{#1}\fi}
  144.    %%\m@rker expands here to \m@@rker since spot initial,
  145.    %% so no confusuion with \m@rker
  146.  
  147.   %%% \Trim@0#1@ trims init and terminal spaces 
  148.    %% Same syntax.
  149.    %% Warns if internal spaces found.
  150.    %% 
  151.   \def\Trim@0#1@{%
  152.       \ForeTrim@0#1@%
  153.       \IN@0 @\the\Trimtoks@ @%
  154.         \ifIN@ 
  155.              \SPLIT@0 @\the\Trimtoks@ @\Trimtoks@\Initialtoks@
  156.              \IN@0\the\Terminaltoks@ @ @%
  157.                  \ifIN@
  158.                  \else \Trimtoks@ {FigNameWithSpace}%
  159.                  \fi
  160.         \fi
  161.       }
  162.  
  163.  
  164.   %%%% MATH MACROS (provisional)
  165.     %% use dimen registers for reals; unit 1pt
  166.     %% (numerical dimension arguments OK unless contrary noted)
  167.  
  168.   %%%% One needs the point token seq (pt with cat 12) USES dimen 0
  169.    \newtoks\pt@ks
  170.    \def\getpt@ks 0.0#1@{\pt@ks{#1}}
  171.    \dimen0=0pt\relax\expandafter\getpt@ks\the\dimen0@
  172.  
  173.    %%% Convert dimen to "decimal multiplier"% USES dimens 0,2
  174.   \newtoks\Realtoks% the output!
  175.   \def\Real#1{%
  176.     \dimen2=#1%
  177.       \SPLIT@0\the\pt@ks @\the\dimen2@%%  lop off the points
  178.        \Realtoks=\Initialtoks@%\showthe\Realtoks
  179.             }
  180.  
  181.    %%% Multiplication 
  182.       % USES dimens 0,2,4,6; preserves args; output \Product
  183.    \newdimen\Product
  184.    \def\Mult#1#2{%
  185.      \dimen4=#1\relax
  186.      \dimen6=#2%
  187.      \Real{\dimen4}%
  188.      \Product=\the\Realtoks\dimen6%
  189.         }
  190.  
  191.    %%% Inverse 
  192.      % USES dimens 0; preserves arg; output \Inverse
  193.  \newdimen\Inverse
  194.  \newdimen\hmxdim@ \hmxdim@=8192pt%halfmaxdimen
  195.  \def\Invert#1{%
  196.   \Inverse=\hmxdim@
  197.   \dimen0=#1%
  198.   \divide\Inverse \dimen0%
  199.   \multiply\Inverse 8}
  200.  
  201.  %%% \Rescale#1#2#3  % USES dimens 0,2,4,6
  202.   %%  alters dimen register #1 by ratio #2/#3 
  203.   %%  where #2,#3 can be raw dimensions OR dimen registers
  204.    \def\Rescale#1#2#3{% Adequate accuracy. Can improve. 
  205.               \divide #1 by 100\relax
  206.               \dimen2=#3\divide\dimen2 by 100 \Invert{\dimen2}% 
  207.               \Mult{#1}{#2}%
  208.               \Mult\Product\Inverse 
  209.               #1=\Product}
  210.  
  211.  %%% \Scale#1 scales dimen register #1 
  212.    %  by dimen register real \TheScale; USES dimens 0
  213.   \def\Scale#1{\dimen0=\TheScale %
  214.       \divide #1 by  1280 %% 1280*5120*10=1000*2^16 
  215.       \divide \dimen0 by 5120 % 
  216.       \multiply#1 by \dimen0 
  217.       \divide#1 by 10   %% max size of #1 about 32000/10 pt
  218.      }
  219.  
  220.  %%% SCRUNCHING BOXES AND SHIFTING CONTENTS
  221.   %% TeX has to do this in general
  222.   %% since some drivers do not let 
  223.   %% one do it readily using Postscript
  224.  
  225.  \newbox\scrunchbox
  226.  
  227.  %%% \Scrunched#1 puts #1 in an hbox
  228.   %%    then in effect zeros the dimensions of this box
  229.  \def\Scrunched#1{{\setbox\scrunchbox\hbox{#1}%
  230.    \wd\scrunchbox=0pt
  231.    \ht\scrunchbox=0pt
  232.    \dp\scrunchbox=0pt
  233.    \box\scrunchbox}}
  234.  
  235.   %%% \Shifted@#1 puts #1 in \hbox 
  236.    %% then locates basepoint to bottom left corner
  237.    %% then translates ink only by \XShift@,\YShift@
  238.    %% with Postscript convention
  239.    %% For simplicity use only on scrunched boxes
  240.   %\newdimen\XShift@ 
  241.   %\newdimen\YShift@ 
  242.  \def\Shifted@#1{%
  243.    \vbox {\kern-\YShift@
  244.        \hbox {\kern\XShift@\hbox{#1}\kern-\XShift@}%
  245.            \kern\YShift@}}
  246.  
  247.   %%% \cBoxedEPSF#1 the main macro
  248.    %%  component macros are explained in order below
  249.  
  250.  \def\cBoxedEPSF#1{{\leavevmode 
  251.     %% double brace for amstex \allign, \alligned, ...
  252.    \ReadNameAndScale@{#1}%
  253.    \SetEPSFSpec@
  254.    \ReadEPSFile@ \ReadBdB@x  
  255.    %% Calculations
  256.      \TrimFigDims@ 
  257.      \CalculateFigScale@  
  258.      \ScaleFigDims@
  259.      \SetInkShift@
  260.    \hbox{$\mathsurround=0pt\relax
  261.          \vcenter{\hbox{%
  262.              \FrameSpider{\hskip-.4pt\vrule}%
  263.              \vbox to \Ht@{\offinterlineskip\parindent=\z@%
  264.                 \FrameSpider{\vskip-.4pt\hrule}\vfil 
  265.                 \hbox to \Wd@{\hfil}%
  266.                 \vfil
  267.                 \InkShift@{\EPSFSpecial{\EPSFSpec@}{\FigSc@leReal}}%
  268.              \FrameSpider{\hrule\vskip-.4pt}}%
  269.          \FrameSpider{\vrule\hskip-.4pt}}}%
  270.      $\relax}%
  271.     \CleanRegisters@ 
  272.     \ms@g{ *** Box composed for the % 
  273.          EPS file \the\EPSFNametoks@}%
  274.     }}
  275.  
  276.  \def\tBoxedEPSF#1{\setbox4\hbox{\cBoxedEPSF{#1}}%
  277.      \setbox4\hbox{\raise -\ht4 \hbox{\box4}}%
  278.      \box4
  279.       }
  280.  
  281.  \def\bBoxedEPSF#1{\setbox4\hbox{\cBoxedEPSF{#1}}%
  282.      \setbox4\hbox{\raise \dp4 \hbox{\box4}}%
  283.      \box4
  284.       }
  285.  
  286.   \let\BoxedEPSF\cBoxedEPSF% default setting
  287.  
  288.   %% Some compatibility with BoxedArt.tex
  289.    %
  290.    \let\BoxedArt\BoxedEPSF
  291.  
  292.   %% Some compatibility with Sweet-teX
  293.    %
  294.   \def\gLinefigure[#1scaled#2]_#3{%
  295.         \BoxedEPSF{#3 scaled #2}}
  296.     
  297.   %% Some compatibility with Rokicki's dvips
  298.    %
  299.   \let\EPSFbox\bBoxedEPSF \let\EPSFfile\bBoxedEPSF
  300.   
  301.   \def\EPSFxsize{\afterassignment\ForceW@\ForcedDim@@}
  302.       \def\ForceW@{\ForcedDim@true\ForcedHeight@false}
  303.   
  304.   \def\EPSFysize{\afterassignment\ForceH@\ForcedDim@@}
  305.       \def\ForceH@{\ForcedDim@true\ForcedHeight@true}
  306.  
  307.   \def\EmulateRokicki{%
  308.        \let\epsfbox\bBoxedEPSF \let\epsffile\bBoxedEPSF
  309.        \let\epsfxsize\EPSFxsize \let\epsfysize\EPSFysize} 
  310.  
  311.  %%% \ReadNameAndScale@#1
  312.   %
  313.  \def\ReadNameAndScale@#1{\IN@0 scaled@#1@% DOUBLE BARRELED
  314.    \ifIN@\ReadNameAndScale@@0#1@%
  315.    \else \ReadNameAndScale@@0#1 scaled\DefaultMilScale @%
  316.    \fi}
  317.   
  318.  \def\ReadNameAndScale@@0#1scaled#2@{% HELPER MACRO
  319.     \let\OldBackslash@\\%
  320.     \def\\{\OtherB@ckslash}%
  321.     \edef\temp@{#1}%
  322.     \Trim@0\temp@ @%
  323.     \EPSFNametoks@\expandafter{\the\Trimtoks@ }%
  324.     \FigScale=#2 pt%
  325.     \let\\\OldBackslash@
  326.     }
  327.  
  328.  \def\SetDefaultEPSFScale#1{%
  329.       \global\def\DefaultMilScale{#1}}
  330.  
  331.  \SetDefaultEPSFScale{1000}
  332.  
  333.  
  334.  %%% \ReadEPSFile@
  335.   %
  336.  \def \SetBogusBbox@{%
  337.      \global\BdBoxtoks@{ BoundingBox:0 0 100 100 }%
  338.      \global\def\BdBoxLine@{ BoundingBox:0 0 100 100 }%
  339.      \ms@g{ !!! Will use placeholder !!!}%
  340.      }
  341.  
  342.  {\catcode`\%=12\gdef\P@S@{%!}\gdef\pct@@{%%}} %% %! min sign of PS file
  343.  
  344.  \def\ReadEPSFile@{%\show\EPSFSpec@%
  345.      \openin\EPSFile@\EPSFSpec@
  346.      \relax  %necessary to prevent precocious expansion of \ifeof
  347.   \ifeof\EPSFile@
  348.      \ms@g{}%
  349.      \ms@g{ !!! EPS FILE \the\EPSFDirectorytoks@
  350.        \the\EPSFNametoks@\space WAS NOT FOUND !!!}%
  351.      \SetBogusBbox@
  352.   \else%\fi
  353.    \begingroup%%
  354.    \catcode`\%=12\catcode`\:=12\catcode`\!=12
  355.    \catcode"00=14 \catcode"7F=14 \catcode`\\=14 
  356.     %% 14 = comment, terminates input line; 
  357.     %% 5 = CR just picks up extra space
  358.    \global\read\EPSFile@ to \BdBoxLine@ %\show\BdBoxLine@
  359.    \IN@0\P@S@ @\BdBoxLine@ @%
  360.    \ifIN@ %% %! accepted as %!PS so do BdBox search!!
  361.      \NotIn@true
  362.      \loop   
  363.        \ifeof\EPSFile@\NotIn@false 
  364.          \ms@g{}%
  365.          \ms@g{ !!! BoundingBox NOT FOUND IN %
  366.             \the\EPSFDirectorytoks@\the\EPSFNametoks@\space!!! }%
  367.          \SetBogusBbox@
  368.        \else\global\read\EPSFile@ to \BdBoxLine@
  369.        %\show\BdBoxLine@
  370.        \fi
  371.        \global\BdBoxtoks@\expandafter{\BdBoxLine@}%
  372.        \IN@0BoundingBox:@\the\BdBoxtoks@ @%
  373.        \ifIN@\NotIn@false\fi%
  374.      \ifNotIn@
  375.      \repeat
  376.    \else
  377.          \ms@g{}%
  378.          \ms@g{ !!! \the\EPSFNametoks@\space is not PostScript.}%
  379.          \ms@g{ !!! It should begin with the "\P@S@". }%
  380.          \ms@g{ !!! Also, all other header lines until }%
  381.          \ms@g{ !!!  "\pct@@ EndComments"  should begin with "\pct@@". }%
  382.          \SetBogusBbox@
  383.    \fi
  384.   \endgroup\relax
  385.   \fi
  386.   \closein\EPSFile@ 
  387.    }
  388.  
  389.  
  390.   %%% \ReadBdB@x
  391.    % Rmk For simplicity 0 not used in syntax 
  392.    %  of \ReadBdB@x@,  \ReadBdB@x@@ 
  393.   \def\ReadBdB@x{% PART 0
  394.    \expandafter\ReadBdB@x@\the\BdBoxtoks@ @}
  395.   
  396.   \def\ReadBdB@x@#1BoundingBox:#2@{% PART 1
  397.     \ForeTrim@0#2@%
  398.     \IN@0atend@\the\Trimtoks@ @%
  399.        \ifIN@\Trimtoks@={0 0 100 100 }%
  400.          \ms@g{}%
  401.          \ms@g{ !!! BoundingBox not found in %
  402.          \the\EPSFDirectorytoks@\the\EPSFNametoks@\space !!!}%
  403.          \ms@g{ !!! It must not be at end of EPSF !!!}%
  404.          \ms@g{ !!! Will use placeholder !!!}%
  405.        \fi%% cf \SetBogusBbox@
  406.     \expandafter\ReadBdB@x@@\the\Trimtoks@ @%
  407.    }
  408.     
  409.   \def\ReadBdB@x@@#1 #2 #3 #4@{% PART 2
  410.       \Wd@=#3bp\advance\Wd@ by -#1bp%
  411.       \Ht@=#4bp\advance\Ht@ by-#2bp%
  412.        \Wd@@=\Wd@ \Ht@@=\Ht@ %% useful info for Clark
  413.        \LLXtoks@={#1}\LLYtoks@={#2}%% useful info for PSprint
  414.       \ifPSOrigin\XShift@=-#1bp\YShift@=-#2bp\fi 
  415.      }
  416.  
  417.   %%% \SetEPSFDirectory 
  418.    %
  419.    \def\G@bbl@#1{}
  420.    \bgroup
  421.      \global\edef\OtherB@ckslash{\expandafter\G@bbl@\string\\}
  422.    \egroup
  423.  
  424.   \def\SetEPSFDirectory{%  Part 1
  425.            \bgroup\PunctOther@\relax
  426.            \let\\\OtherB@ckslash
  427.            \SetEPSFDirectory@}
  428.  
  429.  \def\SetEPSFDirectory@#1{% Part 2
  430.     \edef\temp@{#1}%
  431.     \Trim@0\temp@ @%  result in \Trimtoks@
  432.     \global\toks1\expandafter{\the\Trimtoks@ }\relax
  433.     \egroup
  434.     \EPSFDirectorytoks@=\toks1
  435.     }
  436.  
  437.  \def\SetEPSFSpec@{%
  438.      \bgroup
  439.      \let\\=\OtherB@ckslash
  440.      \global\edef\EPSFSpec@{%
  441.         \the\EPSFDirectorytoks@\the\EPSFNametoks@}%
  442.      \global\edef\EPSFSpec@{\EPSFSpec@}%
  443.      \egroup}
  444.  
  445.  %%% \TrimFigDims@ 
  446.   % 
  447.  \def\TrimTop#1{\advance\TT@ by #1}
  448.  \def\TrimLeft#1{\advance\LT@ by #1}
  449.  \def\TrimBottom#1{\advance\BT@ by #1}
  450.  \def\TrimRight#1{\advance\RT@ by #1}
  451.  
  452.  \def\TrimBoundingBox#1{%
  453.    \TrimTop{#1}%
  454.    \TrimLeft{#1}%
  455.    \TrimBottom{#1}%
  456.    \TrimRight{#1}%
  457.        }
  458.  
  459.  \def\TrimFigDims@{%
  460.     \advance\Wd@ by -\LT@ 
  461.     \advance\Wd@ by -\RT@ \RT@=\z@
  462.     \advance\Ht@ by -\TT@ \TT@=\z@
  463.     \advance\Ht@ by -\BT@ 
  464.     }
  465.  
  466.  
  467.  %%% \CalculateFigScale@
  468.   %
  469.   \def\ForceWidth#1{\ForcedDim@true
  470.        \ForcedDim@@#1\ForcedHeight@false}
  471.   
  472.   \def\ForceHeight#1{\ForcedDim@true
  473.        \ForcedDim@@=#1\ForcedHeight@true}
  474.  
  475.   \def\ForceOn{\ForceOn@true}
  476.   \def\ForceOff{\ForceOn@false\ForcedDim@false}
  477.   
  478.   \def\CalculateFigScale@{%
  479.             %Have default \FigScale or read \FigScale
  480.      \ifForcedDim@\FigScale=1000pt% %% start afresh
  481.            \ifForcedHeight@
  482.                 \Rescale\FigScale\ForcedDim@@\Ht@
  483.            \else
  484.                 \Rescale\FigScale\ForcedDim@@\Wd@
  485.            \fi
  486.      \fi
  487.      \Real{\FigScale}%
  488.      \edef\FigSc@leReal{\the\Realtoks}%
  489.      }
  490.    
  491.   \def\ScaleFigDims@{\TheScale=\FigScale
  492.       \ifForcedDim@
  493.            \ifForcedHeight@ \Ht@=\ForcedDim@@  \Scale\Wd@
  494.            \else \Wd@=\ForcedDim@@ \Scale\Ht@
  495.            \fi
  496.       \else \Scale\Wd@\Scale\Ht@        
  497.       \fi
  498.       \ifForceOn@\relax\else\global\ForcedDim@false\fi
  499.       \Scale\LT@\Scale\BT@  %%%\Scale\Wd@\Scale\Ht@
  500.       \Scale\XShift@\Scale\YShift@
  501.       }
  502.       
  503.   %%% \ShowDisplacementBoxes
  504.    %%  shows (prints) corrected scaled and positioned
  505.    %%  bounding boxes; for diagnostics
  506.   %%% \HideDisplacementBoxes makes them invisible again
  507.    %%
  508.  \def\HideDisplacementBoxes{\global\def\FrameSpider##1{\null}}
  509.  \def\ShowDisplacementBoxes{\global\def\FrameSpider##1{##1}}
  510.  %\let\HideDisplacementBoxes\HideReservedBoxes  %% some synonyms
  511.  %\let\ShowDisplacementBoxes\ShowReservedBoxes
  512.  \let\HideFigureFrames\HideDisplacementBoxes %% some synonyms
  513.  \let\ShowFigureFrames\ShowDisplacementBoxes
  514.  \ShowDisplacementBoxes
  515.  
  516.   %%% \hSlide#1, \vSlide#1
  517.    %%
  518.  \def\hSlide#1{\advance\XSlide@ by #1}
  519.  \def\vSlide#1{\advance\YSlide@ by #1}
  520.  
  521.   %%% \SetInkShift@, \InkShift@#1
  522.    %%
  523.   \def\SetInkShift@{%
  524.             \advance\XShift@ by -\LT@
  525.             \advance\XShift@ by \XSlide@
  526.             \advance\YShift@ by -\BT@
  527.             \advance\YShift@ by -\YSlide@
  528.              }
  529.    %
  530.   \def\InkShift@#1{\Shifted@{\Scrunched{#1}}}
  531.  
  532.   %%% \CleanRegisters@
  533.    %
  534.   \def\CleanRegisters@{%
  535.       \globaldefs=1\relax
  536.         \XShift@=\z@\YShift@=\z@\XSlide@=\z@\YSlide@=\z@
  537.         \TT@=\z@\LT@=\z@\BT@=\z@\RT@=\z@
  538.       \globaldefs=0\relax}
  539.  
  540.  %%% Special syntax for several drivers. The macros 
  541.   %% \SetTexturesEPSFSpecial  %% Textures 
  542.   %% \SetUnixCoopEPSFSpecial %% dvi2ps early unix 
  543.   %% \SetBechtolsheimDVI2PSEPSFSpecial and 
  544.   %% \SetBechtolsheimDVITPSEPSFSpecial %% by S.P.Bechtolsheim
  545.   %% \SetLisEPSFSpecial %% dvi2ps by Tony Lis
  546.   %% \SetRokickiEPSFSpecial  %% dvips by Tom Rokicki
  547.   %%  --- also for DVIReader, in DirectTeX by W. Ricken
  548.   %% \SetOzTeXEPSFSpecial  %% OzTeX (>= 1.7) by Andrew Trevorrow
  549.   %% \SetPSprintEPSFSpecial %% PSprint by Andrew Trevorrow
  550.   %%  --- also for OzTeX versions <= 1.41 !!
  551.   %% \SetArborEPSFSpecial  %% ArborTeX DVILASER/PS
  552.   %% \SetClarkEPSFSpecial %% dvitops by James Clark
  553.   %% \SetDVIPSoneEPSFSpecial %% DVIPSONE of Y&Y 
  554.   %% \SetBeebeEPSFSpecial %% DVIALW by N. Beebe
  555.   %% \SetNorthlakeEPSFSpecial %% Northlake Software
  556.   %% \SetStandardEPSFSpecial %% Nonexistant: Placebo below
  557.   %% Many drivers supported roughly
  558.   %% by (re-)defining the macro \EPSFSpecial#1#2, where
  559.   %% #1 = EPS file pathname (use \\ for the letter backslash)
  560.   %% #2 = scale in mils 
  561.   %% Be wary of using strange characters in pathnames!
  562.  
  563.  %% Textures, Blue Sky Research, Barry Smith
  564.  \def\SetTexturesEPSFSpecial{\PSOriginfalse%\PSOrigintrue
  565.   \gdef\EPSFSpecial##1##2{\relax
  566.     \edef\specialtemp{##2}%
  567.     \SPLIT@0.@\specialtemp.@\relax
  568.     \special{illustration ##1 scaled
  569.                         \the\Initialtoks@}}}
  570.  
  571.   %% Unix : dvi2ps by:  Mark Senn, Stephan  Bechtolsheim,  
  572.    % Bob  Brown, Richard, Furuta, James Schaad, Robert  Wells, 
  573.    % Norm Hutchinson, Neal Holt, Scott Jones, Howard Trickey.
  574.    % Introduced by B. Horn <bkph@ai.mit.edu>
  575.   \def\SetUnixCoopEPSFSpecial{\PSOrigintrue % Please test!
  576.    \gdef\EPSFSpecial##1##2{%
  577.       \dimen4=##2pt% convert real to dimen
  578.       \divide\dimen4 by 1000\relax
  579.       \Real{\dimen4}%dimens 0,2 used here
  580.       \edef\Aux@{\the\Realtoks}%  
  581.       %%convert dimen to real
  582.       \special{psfile=##1\space 
  583.         hscale=\Aux@\space
  584.         vscale=\Aux@}}}
  585.  
  586.  
  587.   %% dvi2ps and dvitps by S.P. Bechtolsheim,
  588.    % Introduced by B. Horn <bkph@ai.mit.edu> and Carl.M.Jones, 
  589.    % testing by R. Evans <Robert@cm.cardiff.ac.uk>
  590.    % and George Denk <denk@mathematik.tu-muenchen.de>
  591.    % Note that a prolog file psfig.pro
  592.    % specific to the driver should be available.
  593.   \def\SetBechtolsheimEPSFSpecial@{%% tool macro only
  594.    \PSOrigintrue
  595.    \special{\DriverTag@ Include0 "psfig.pro"}%
  596.    \gdef\EPSFSpecial##1##2{%
  597.       \dimen4=##2pt %% convert real to dimen
  598.       \divide\dimen4 by 1000\relax
  599.       \Real{\dimen4} %% dimens 0,2 used here
  600.       \edef\Aux@{\the\Realtoks}%% convert dimen to real
  601.       \special{\DriverTag@ Literal "10 10 0 0 10 10 startTexFig
  602.            \the\mag\space 1000 div 
  603.            dup 3.25 neg mul 1 index .25 neg mul translate %% correction line
  604.            \Aux@\space mul dup scale "}%
  605.       \special{\DriverTag@ Include1 "##1"}%
  606.       \special{\DriverTag@ Literal "endTexFig "}%
  607.         }}
  608.  
  609.   \def\SetBechtolsheimDVITPSEPSFSpecial{\def\DriverTag@{dvitps: }%
  610.       \SetBechtolsheimEPSFSpecial@}
  611.  
  612.   \def\SetBechtolsheimDVI2PSEPSFSSpecial{\def\DriverTag@{DVI2PS: }%
  613.       \SetBechtolsheimEPSFSpecial@}
  614.  
  615.   %% dvi2ps by Tony Lis,
  616.    % implantations? ; dates?; availability?
  617.    % Introduced by B. Horn <bkph@ai.mit.edu>
  618.   \def\SetLisEPSFSpecial{\PSOrigintrue 
  619.    \gdef\EPSFSpecial##1##2{%
  620.       \dimen4=##2pt% convert real to dimen
  621.       \divide\dimen4 by 1000\relax
  622.       \Real{\dimen4}% dimens 0,2 used here
  623.       \edef\Aux@{\the\Realtoks}%  
  624.       %%convert dimen to real
  625.       \special{pstext="10 10 0 0 10 10 startTexFig\space
  626.            \the\mag\space 1000 div \Aux@\space mul 
  627.            \the\mag\space 1000 div \Aux@\space mul scale"}%
  628.       \special{psfile=##1}%
  629.       \special{pstext=endTexFig}%
  630.         }}
  631.  
  632.   %% dvips by Tom Rokicki; free driver in portable C 
  633.    % Introduced by W.D. Neumann <neumann@mps.ohio-state.edu>
  634.   \def\SetRokickiEPSFSpecial{\PSOrigintrue 
  635.    \gdef\EPSFSpecial##1##2{%
  636.       \dimen4=##2pt% convert real to dimen
  637.       \divide\dimen4 by 10\relax
  638.       \Real{\dimen4}% dimens 0,2 used here
  639.       \edef\Aux@{\the\Realtoks}%  
  640.       %%convert dimen to real
  641.       \special{psfile="##1"\space 
  642.         hscale=\Aux@\space
  643.         vscale=\Aux@}}}
  644.  
  645.   \def\SetInlineRokickiEPSFSpecial{\PSOrigintrue 
  646.    \gdef\EPSFSpecial##1##2{%
  647.       \dimen4=##2pt% convert real to dimen
  648.       \divide\dimen4 by 1000\relax
  649.       \Real{\dimen4}% dimens 0,2 used here
  650.       \edef\Aux@{\the\Realtoks}%  
  651.       %%convert dimen to real
  652.       \special{ps::[begin] 10 10 0 0 10 10 startTexFig\space
  653.            \the\mag\space 1000 div \Aux@\space mul 
  654.            \the\mag\space 1000 div \Aux@\space mul scale}%
  655.       \special{ps: plotfile ##1}%
  656.       \special{ps::[end] endTexFig}%
  657.         }}
  658.  
  659.  %%% OzTeX (versions 1.7 and later), by Andrew Trevorrow.
  660.  %%% Change to \PSOrigintrue for OzTeX versions 1.42 to 1.6.
  661.  \def\SetOzTeXEPSFSpecial{\PSOriginfalse
  662.  \gdef\EPSFSpecial##1##2{%
  663.  \dimen4=##2pt%% convert real to dimen
  664.  \divide\dimen4 by 1000\relax
  665.  \Real{\dimen4}%% dimens 0,2 used here
  666.  \edef\Aux@{\the\Realtoks}%% convert dimen to real
  667.  \special{epsf=\string"##1\string"\space scale=\Aux@}%
  668.  }} 
  669.  
  670.  %% PSprint, by AndrewTrevorrow for VaX VMS
  671.  %% and OzTeX versions <= 1.41  
  672.   % tested 2-91 by Max Calviani <ISICA@ASTRPD.infn.it>
  673.   \def\SetPSprintEPSFSpecial{\PSOriginFALSE % artifice; see below
  674.    \gdef\EPSFSpecial##1##2{%note order
  675.      \special{##1\space 
  676.        ##2 1000 div \the\mag\space 1000 div mul
  677.        ##2 1000 div \the\mag\space 1000 div mul scale
  678.        \the\LLXtoks@\space neg \the\LLYtoks@\space neg translate
  679.        }}}
  680.  
  681.  %% DVILASER/PS driver originally written by David Fuchs
  682.   % marketed and supported by ArborTeXt  535 W. William St.
  683.   % Suite 300, Ann Arbor, MI 48103, U.S.A
  684.   % (313) 996-3566 (313) 996-3573
  685.   % help@arbortext.com, Andrew Dobrowolski
  686.  \def\SetArborEPSFSpecial{\PSOriginfalse % check!
  687.    \gdef\EPSFSpecial##1##2{%
  688.      \edef\specialthis{##2}%
  689.      \SPLIT@0.@\specialthis.@\relax % suppress decimals (nec!)
  690.      \special{ps: epsfile ##1\space \the\Initialtoks@}}}
  691.  
  692.  %% dvitops, (c) James Clark <jjc@jclark.uucp>
  693.   % public domain; distributed by UK TeX Archive
  694.   % computers: unix, msdos, vms, primos and vm/cms,
  695.   % introduced by S. Ratz <spqr@uk.ac.southampton.ecs>
  696.  \def\SetClarkEPSFSpecial{\PSOriginfalse % please test!
  697.    \gdef\EPSFSpecial##1##2{%
  698.      \Rescale {\Wd@@}{##2pt}{1000pt}%
  699.      \Rescale {\Ht@@}{##2pt}{1000pt}%
  700.      \special{dvitops: import 
  701.            ##1\space\the\Wd@@\space\the\Ht@@}}}
  702.  
  703.  %% DVIPSONE, for PC compatibles
  704.   % Y&Y, 106 Indian Hill, Carlisle MA 01741, USA
  705.   % (508) 371-3286
  706.   % (introduced by B. Horn <bkph@ai.mit.edu>)
  707.   \let\SetDVIPSONEEPSFSpecial\SetUnixCoopEPSFSpecial
  708.   \let\SetDVIPSoneEPSFSpecial\SetUnixCoopEPSFSpecial
  709.  
  710.  %% DVIALW by N. Beebe, public domain 
  711.   % DVI Driver Distribution, Center for Scientific Computing,
  712.   % Department of Mathematics, 220 South Physics Building,
  713.   % University of Utah, Salt Lake City, UT 84112, USA
  714.   % (introduced by B. Horn <bkph@ai.mit.edu>)
  715.   % Proposed standard; see TUGboat article 1993.
  716.   \def\SetBeebeEPSFSpecial{%please test!
  717.    \PSOriginfalse% 
  718.    \gdef\EPSFSpecial##1##2{\relax
  719.     \special{language "PS",
  720.       literal "##2 1000 div ##2 1000 div scale",
  721.       position = "bottom left",
  722.       include "##1"}}}
  723.   \let\SetDVIALWEPSFSpecial\SetBeebeEPSFSpecial
  724.  
  725.  %% Northlake software
  726.   \def\SetNorthlakeEPSFSpecial{\PSOrigintrue
  727.    \gdef\EPSFSpecial##1##2{%
  728.      \edef\specialthis{##2}%
  729.      \SPLIT@0.@\specialthis.@\relax % suppress decimals (nec!)
  730.      \special{insert ##1,magnification=\the\Initialtoks@}}}
  731.  
  732.  \def\SetStandardEPSFSpecial{%
  733.    \gdef\EPSFSpecial##1##2{%
  734.      \ms@g{}
  735.      \ms@g{%
  736.        !!! Sorry! There is still no standard for \string%
  737.        \special\space EPSF integration !!!}%
  738.      \ms@g{%
  739.       --- So you will have to identify your driver using a command}%
  740.      \ms@g{%
  741.       --- of the form \string\Set...EPSFSpecial, in order to get}%
  742.      \ms@g{%
  743.       --- your graphics to print.  See BoxedEPS.doc.}%
  744.      \ms@g{}
  745.      \gdef\EPSFSpecial####1####2{}
  746.      }}
  747.  
  748.   \SetStandardEPSFSpecial %% currently gives warning
  749.  
  750.  \let\wlog\wlog@ld %%restore logging 
  751.  
  752.  \catcode`\:=\C@tColon
  753.  \catcode`\;=\C@tSemicolon
  754.  \catcode`\?=\C@tQmark
  755.  \catcode`\!=\C@tEmark
  756.  \catcode`\"=\C@tDqt
  757.  
  758.  \catcode`\@=\EPSFCatAt
  759.  
  760.   \endinput
  761.  
  762. %%%%%%%%%%%% ASCII Character test
  763.  %
  764.  %       Upper case letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  765.  %       Lower case letters: abcdefghijklmnopqrstuvwxyz
  766.  %                                   Digits: 0123456789
  767.  % Square, curly, angle braces, parentheses: [] {} <> ()
  768.  %           Backslash, slash, vertical bar: \ / |
  769.  %                              Punctuation: . ? ! , : ;
  770.  %          Underscore, hyphen, equals sign: _ - =
  771.  %                Quotes--right left double: ' ` "
  772.  %"at", "number" "dollar", "percent", "and": @ # $ % &
  773.  %           "hat", "star", "plus", "tilde": ^ * + ~
  774.  %
  775.  %%%%%%%%%%%%%%%%%%%%%%%%
  776.  %
  777.  % Une seule erreur de transmission peut empoisoner un programme!
  778.  %
  779.  % A single transmission error can poison a whole program.
  780.  %
  781.  %%%%%%%%%%%%%%%%%%%%%%%%
  782.